/**
 * This file is released under the GNU General Public License.
 * Refer to the COPYING file distributed with this package.
 *
 * Copyright (c) 2008-2009 WURFL-Pro srl
 */
package net.sourceforge.wurfl.core.handlers;

import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;

import net.sourceforge.wurfl.core.request.normalizer.specific.ChromeNormalizer;
import net.sourceforge.wurfl.core.request.normalizer.specific.FirefoxNormalizer;
import net.sourceforge.wurfl.core.request.normalizer.specific.KonquerorNormalizer;
import net.sourceforge.wurfl.core.request.normalizer.specific.MSIENormalizer;
import net.sourceforge.wurfl.core.request.normalizer.specific.NullNormalizer;
import net.sourceforge.wurfl.core.request.normalizer.specific.OperaNormalizer;
import net.sourceforge.wurfl.core.request.normalizer.specific.SafariNormalizer;

import org.apache.commons.collections.map.UnmodifiableMap;

/**
 * A factory for user-agent {@link Handler}.
 * 
 * <p>
 * This class build a {@link Map} of user-agent {@link Handler} by a key.
 * </p>
 * 
 * @author WURFL-PRO SRL, Rome, Italy
 * @version $Id: HandlersFactory.java 1045 2009-03-09 15:52:53Z filippo.deluca $
 */
public class HandlersFactory {

	private static Map handlers = new LinkedHashMap();

	static {
		NullNormalizer nullNormalizer = new NullNormalizer();
		ChromeNormalizer chromeNormalizer = new ChromeNormalizer();
		OperaNormalizer operaNormalizer = new OperaNormalizer();
		KonquerorNormalizer konquerorNormalizer = new KonquerorNormalizer();
		SafariNormalizer safariNormalizer = new SafariNormalizer();
		FirefoxNormalizer firefoxNormalizer = new FirefoxNormalizer();
		MSIENormalizer msieNormalizer = new MSIENormalizer();
		
		handlers.put(HandlerConstants.VODAFONE, new VodafoneHandler(nullNormalizer));
		handlers.put(HandlerConstants.NOKIA, new NokiaHandler(nullNormalizer));

		handlers.put(HandlerConstants.SONY_ERICSSON, new SonyEricssonHandler(nullNormalizer));

		handlers.put(HandlerConstants.MOTOROLA, new MotorolaHandler(nullNormalizer));
		handlers.put(HandlerConstants.BLACKBERRY, new BlackBerryHandler(nullNormalizer));

		handlers.put(HandlerConstants.SIEMENS, new SiemensHandler(nullNormalizer));
		handlers.put(HandlerConstants.SAGEM, new SagemHandler(nullNormalizer));

		handlers.put(HandlerConstants.SAMSUNG, new SamsungHandler(nullNormalizer));
		handlers.put(HandlerConstants.PANASONIC, new PanasonicHandler(nullNormalizer));

		handlers.put(HandlerConstants.NEC, new NecHandler(nullNormalizer));
		handlers.put(HandlerConstants.QTEK, new QtekHandler(nullNormalizer));

		handlers.put(HandlerConstants.MITSUBISHI, new MitsubishiHandler(nullNormalizer));
		handlers.put(HandlerConstants.PHILIPS, new PhilipsHandler(nullNormalizer));

		handlers.put(HandlerConstants.LG, new LGHandler(nullNormalizer));
		handlers.put(HandlerConstants.APPLE, new AppleHandler(nullNormalizer));

		handlers.put(HandlerConstants.KYOCERA, new KyoceraHandler(nullNormalizer));
		handlers.put(HandlerConstants.ALCATEL, new AlcatelHandler(nullNormalizer));

		handlers.put(HandlerConstants.SHARP, new SharpHandler(nullNormalizer));
		handlers.put(HandlerConstants.SANYO, new SanyoHandler(nullNormalizer));

		handlers.put(HandlerConstants.BENQ, new BenQHandler(nullNormalizer));
		handlers.put(HandlerConstants.PANTECH, new PantechHandler(nullNormalizer));

		handlers.put(HandlerConstants.TOSHIBA, new ToshibaHandler(nullNormalizer));
		handlers.put(HandlerConstants.GRUNDIG, new GrundigHandler(nullNormalizer));

		handlers.put(HandlerConstants.HTC, new HTCHandler(nullNormalizer));
		handlers.put(HandlerConstants.SPV, new SPVHandler(nullNormalizer));

		handlers.put(HandlerConstants.WINDOWS_CE, new WindowsCEHandler(nullNormalizer));
		handlers.put(HandlerConstants.PORTALMMM, new PortalmmmHandler(nullNormalizer));

		handlers.put(HandlerConstants.DOCOMO, new DoCoMoHandler(nullNormalizer));
		handlers.put(HandlerConstants.KDDDI, new KDDIHandler(nullNormalizer));
		
		handlers.put(HandlerConstants.ANDROID, new AndroidHandler(nullNormalizer));
		handlers.put(HandlerConstants.OPERA_MINI, new OperaMiniHandler(nullNormalizer));
		
		handlers.put(HandlerConstants.BOT, new BotHandler(nullNormalizer));
		handlers.put(HandlerConstants.CHROME, new ChromeHandler(chromeNormalizer));
		handlers.put(HandlerConstants.AOL, new AOLHandler(nullNormalizer));
		handlers.put(HandlerConstants.OPERA, new OperaHandler(operaNormalizer));
		handlers.put(HandlerConstants.KONQUEROR, new KonquerorHandler(konquerorNormalizer));
		handlers.put(HandlerConstants.SAFARI, new SafariHandler(safariNormalizer));
		handlers.put(HandlerConstants.FIREFOX, new FirefoxHandler(firefoxNormalizer));
		handlers.put(HandlerConstants.MSIE, new MSIEHandler(msieNormalizer));
		
		handlers.put(HandlerConstants.CATCH_ALL, new CatchAllHandler(nullNormalizer));
	}

	/**
	 * Return the {@link Map} containig the {@link Handler}s. It is a
	 * {@link UnmodifiableMap}.
	 * 
	 * @return A {@link UnmodifiableMap} containig the {@link Handler} by
	 *         handlers key.
	 */
	public Map create() {
		return Collections.unmodifiableMap(handlers);
	}
}